﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FangDuShi_Admin.BLL
{
    /// <summary>
    /// 手机验证码 逻辑类
    /// </summary>
    public class MobileCAPTCHA
    {
        /// <summary>
        /// 手机验证码DAL
        /// </summary>
        private DAL.MobileCAPTCHA mobileCAPTCHADAL = new DAL.MobileCAPTCHA();
        public MobileCAPTCHA()
        { }
        /// <summary>
        /// 增加一条数据
        /// 间隔时间interval 分钟
        /// </summary>
        public void Add(FangDuShi_Admin.Model.MobileCAPTCHA model, int interval)
        {
            mobileCAPTCHADAL.Add(model, interval);
        }
        /// <summary>
        /// 判断是否允许发送手机验证码
        /// 1、时间间隔为120秒
        /// 2、每个IP最多不超过20条(同一天)，特殊IP地址除外（系统需要建立IP白名单）
        /// 3、每个手机号码一天最多发送3条
        /// 4、经纪人忘记密码时，需要输入真是的手机号码和真实姓名，否则不发送验证码
        /// <param name="mobile">手机号码</param>
        /// <param name="interval">发送时间间隔</param>
        /// <param name="ipCount">每个IP同一天最多条数</param>
        /// <param name="mobileCount">每个手机号码同一天最多条数</param>
        /// <param name="ipAddress">ip地址</param>
        /// <param name="errorMsg">错误消息</param>
        /// </summary>
        /// <returns></returns>
        public bool CheckCanSendCAPTCHA(string mobile, int interval, int ipCount, int mobileCount, string ipAddress, out string errorMsg)
        {
            return mobileCAPTCHADAL.CheckCanSendCAPTCHA(mobile, interval, ipCount, mobileCount, ipAddress, out errorMsg);
        }
    }
}
